import axios from 'axios';

const server =  axios.create({
    baseURL:'https://www.liulongbin.top:8888/api/private/v1',
    timeout:4000
})
// 请求拦截器
server.interceptors.request.use(config=>{
    let data = sessionStorage.getItem('user');
    if(data != null){
        config.headers['Authorization'] = data
    }
    return config
},err=>{
    return Promise.reject(err)
})

// 响应拦截器
server.interceptors.response.use(response=>{
    return response
},err=>{
    return Promise.reject(err)
})

let Request = (params)=>{
    return new Promise((resolve,reject)=>{
        server({
            ...params
        }).then(res=>{
            resolve(res)
        }).catch(err=>{
            reject(err)
        })
    })
}
export default Request
